package com.xhd.db;

import com.xhd.base.log.Log;
import com.xhd.base.log.LogFactory;
import com.xhd.base.util.xBaseObj;
import com.xhd.exception.DatabaseException;
import com.xhd.server.ProcessHandle;
import com.xhd.server.ProcessHandleMgr;
import com.xhd.server.ServerConfig;

public final class XDao extends BizObjDaoImpl
implements DBCenter
{
private DBControls jm116 = null;
private static final Log jm9;
static Class jm10;

static
{
  Class tmp3_0 = jm10;
  if (tmp3_0 == null)
  {
   
    try
    {
       XDao.jm10 = Class.forName("com.xhd.db.XDao");
    }
    catch (ClassNotFoundException localClassNotFoundException)
    {
      throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
    }
  }
  jm9 = LogFactory.getLog(tmp3_0);
}

public XDao(xBaseObj paramBusinessClass, String paramString)
{
  super(ServerConfig.UseDBArea);
  if ((paramString == null) && (((paramBusinessClass == null) || (paramBusinessClass.getVaultInfo() == null))))
  {
    jm9.error("can't new CPCDao, obj no vault.");
    return;
  }
  this.Creator = paramBusinessClass;
  if (paramString == null)
    paramString = paramBusinessClass.getVaultInfo().getVaultId();
  this.jm116 = new DBControls(paramString);
  setDBControls(this.jm116);
}

public XDao(String paramString)
{
  super(ServerConfig.UseDBArea);
  this.jm116 = new DBControls(paramString);
  setDBControls(this.jm116);
  ProcessHandle localProcessHandle = ProcessHandleMgr.getHandle();
  if (localProcessHandle == null)
    return;
  this.Creator = localProcessHandle.getBizObj();
}

public int getDBType()
{
  return this.jm116.getDBType();
}

public DBConfig getDBConfig()
{
  try
  {
    DBControl localDBControl = this.jm116.getByArea(null);
    if (localDBControl != null)
      return localDBControl.getConfig();
  }
  catch (Exception localException)
  {
  }
  return null;
}

public void setTransation(boolean paramBoolean)
{
  this.jm116.setTransation(null, paramBoolean);
}

public void commit()
  throws DatabaseException
{
  this.jm116.commit();
}

public void commitContinue()
  throws DatabaseException
{
  this.jm116.commitContinue();
}

public void rollback()
{
  this.jm116.rollback();
}

public void freeConnection()
{
  this.jm116.freeConnection();
}

public int kill()
{
  return this.jm116.kill();
}

public int getDBConnCount()
{
  return this.jm116.getDBConnCount();
}

public String getUseInfo(boolean paramBoolean)
{
  return this.jm116.getUseInfo(paramBoolean);
}

public int execute(String paramString)
  throws DatabaseException
{
  DBControl localDBControl = getControl(getTable(paramString));
  paramString = bizListener.onExecuteSQL(this.Creator, paramString, localDBControl.getDBType());
  return localDBControl.execute(paramString);
}

public int execute(DBSQL paramDBSQL)
  throws DatabaseException
{
  DBControl localDBControl = getControl(getTable(paramDBSQL.getSQL()));
  bizListener.onExecuteSQL(this.Creator, paramDBSQL, localDBControl.getDBType());
  return localDBControl.execute(paramDBSQL);
}

public int update(String paramString)
  throws DatabaseException
{
  return execute(paramString);
}

public int delete(String paramString)
  throws DatabaseException
{
  return execute(paramString);
}

public String getVaultId()
{
  return this.jm116.getValueId();
}
}